Day 9 - Fields

Solutions to exercises

Exercise 9.01

Print fields 1,6,7, and 8 of the file simple.log

Solution

You can either use cut directly

$ cut simple.log -d " " -f 1,6-8

83.149.9.216 200 203023 http://semicomplete.com/presentations/logstash-monitorama-20\

13/

83.149.9.216 200 171717 http://semicomplete.com/presentations/logstash-monitorama-20\

13/

83.149.9.216 200 26185 http://semicomplete.com/presentations/logstash-monitorama-201\

3/

[...]

or use cat and a pipe

$ cat simple.log | cut -d " " -f 1,6-8

83.149.9.216 200 203023 http://semicomplete.com/presentations/logstash-monitorama-20\

13/

83.149.9.216 200 171717 http://semicomplete.com/presentations/logstash-monitorama-20\

13/

83.149.9.216 200 26185 http://semicomplete.com/presentations/logstash-monitorama-201\

3/

[...]

Go back to the exercise

Exercise 9.02

Extract the time of each request as HH:MM:SS